/**
  \mainpage
  ETFAna project, Anyang Normal University && IMP-CAS
  \brief analyse the raw data, including data mapping, tracking and PID
  \author SUN Yazhou, asia.rabbit@163.com
  \since 2024-05-09
  \date 2024-05-09 last modified
  \attention
  changelog
  <table>
  <tr>  <th>Date         <th>Author      <th>Description                   </tr>
  <tr>  <td>2024-05-09   <td>Asia Sun    <td>file created                  </tr>
  </table>

  \copyright Copyright (c) 2021-2024 Anyang Normal U. && IMP-CAS with LGPLv3 LICENSE
*/

#include <iostream>
#include <unistd.h>
#include <TApplication.h>
#include "ETFGana.h"
#include "ETFParaManager.h"
#include "ETFRun.h"
#include "ETFUnpackTask.h"
#include "ETFGanaPre.h"
#include "ETFMath.h"
#include "ETFMsg.h"

using std::cout;
using std::cerr;
using std::endl;

int main(int argc, char *argv[]){
  cout << "\n\033[32;1m ----------- "
    "Welcome to ETFAna Offline Anaysis GUI System ------------\033[0m" << endl;
  ETFMsg::Logo();
  cout << endl;

  string rtf = "";
  if(argc > 1){
    if(ETFMath::endwith(argv[1], ".root")) rtf = argv[1];
    else ETFParaManager::Instance()->GetOpt(argc, argv);
  } // end if
  TApplication *app = new TApplication("ETFAna Offline Analysis", &argc, argv);
  ETFGana *gana = new ETFGana(rtf);
  ETFRun *run = ETFRun::Instance();
  // run->AddTask(new ETFUnpackTask());
  gana->Initialize(); // construct the buttons
  run->SetOfflineGUI(gana->GetGanaPre());
  gana->Configure(); // show the graphics
  app->Run();

  return 0;
} // end the main function
